#include <head.h>

int main(int argc, char const *argv[])
{
    int pid = 0;
    if (-1==(pid=fork()))
    {
        perror("fork error");
        return 0;
    }
    
    //父进程
    else if (0<pid)
    {
        printf("I'm parent process, my pid is %d\n", getpid());
        sleep(1);
    }

    //子进程
    else
    {
        printf("I'm child process, my pid is %d\n", getpid());
        sleep(2);
        printf("child process ended\n");
        exit(-1);
    }

    wait(NULL);

    printf("I'm child process succeeded closed\n");

    while(1)
    {
        sleep(1);
    }
    return 0;
}
